/*
 * Copyright (c) 2024 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include "napi/native_api.h"
#include <string>
#include <pag/file.h>
#include <pag/pag.h>

namespace NativeXComponentSample {
extern std::shared_ptr<pag::PAGFile> g_pagFile;
class PAGFile {
public:
    PAGFile(napi_env pEnv);
    PAGFile(napi_env pEnv, napi_ref pRef);
    ~PAGFile();
    static napi_value LoadFromPath(napi_env env, napi_callback_info info);
    static napi_value JsFileConstructor(napi_env env, napi_callback_info info);
    static void Destructor(napi_env env, void *nativeObject, void *finalize); // 释放资源的函数(类似类的析构函数)
    static napi_value SetDuration(napi_env env, napi_callback_info info);
    static napi_value SetStartTime(napi_env env, napi_callback_info info);
    static napi_value Duration(napi_env env, napi_callback_info info);
    static napi_ref sJSFileConstructor_;                                      // 生命周期变量
    static napi_value NumImage(napi_env env, napi_callback_info info);        // 可替换图像的数量
    static napi_value NumTexts(napi_env env, napi_callback_info info);        // 可编辑文本的数量
    static napi_value NumVideos(napi_env env, napi_callback_info info);       // 视频作品的数量
    static napi_value Path(napi_env env, napi_callback_info info); // 该文件的路径字符串，如果文件是从字节流加载的，则返回空字符串
    static napi_value MaxSupportedTagLevel(napi_env env, napi_callback_info info); // 当前SDK支持的大标记级别
    static napi_value GetEditableIndices(napi_env env, napi_callback_info info); // 返回此PAGFile中可编辑层的索引
    static napi_value TimeStretchMode(napi_env env, napi_callback_info info); // 指示当文件的持续时间更改时，如何拉伸原始持续时间以适应目标持续时间
    static napi_value TagLevel(napi_env env, napi_callback_info info); // 此pag文件所需的标记级别
    static napi_value SetTimeStretchMode(napi_env env, napi_callback_info info); // 此pag文件所需的标记级别

private:
    static std::string _msg; // 设置和获取数据的变量
    napi_env mEnv = nullptr; // 记录环境变量
    napi_ref mRef = nullptr; // 记录生命周期变量
};
}